package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.SystemColor;

import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import skyproc.Mod;
import skyproc.SPDatabase;
import edit.HolderInterface;

public class CustomTreeCellRenderer extends DefaultTreeCellRenderer {

	private boolean			bSelected;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8986511831939797492L;

	public CustomTreeCellRenderer() {
		super();

		Icon icon = null;

		setLeafIcon(icon);
        setClosedIcon(icon);
        setOpenIcon(icon);

		
	}
	
	
	
	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
		
		
		super.getTreeCellRendererComponent(
                tree, value, sel,
                expanded, leaf, row,
                hasFocus);
		
		
		setText(((HolderInterface) value).getDescription());
		
		return this;

	}
	
	public void paint( Graphics g )
	{
		Color		bColor;
		Icon		currentI = getIcon();

		// Set the correct background color
		bColor = bSelected ? SystemColor.textHighlight : Color.white;
		g.setColor( bColor );

		// Draw a rectangle in the background of the cell
		g.fillRect( 0, 0, getWidth() - 1, getHeight() - 1 );

		super.paint( g );
	}

}
